
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
	<meta name="renderer" content="webkit"> 
    <title><%=siteName + ' - ' + siteAbout%></title>
    <link rel="icon" type="image/icon" href="<%=siteIcon%>">
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/hljs.min.css" />
    <link rel="stylesheet" type="text/css" href="css/asciinema-player.css" />
    <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="js/highlight.min.js"></script>
    <script type="text/javascript" src="js/asciinema-player.js"></script>
</head>
<body>
    <% include header.html %>
    <div id="doc-container">
        <div id="doc-bg"></div>
        <div id="doc-area">
            <h3>NodeJs场景下的使用示例：</h3>
            <p>以下基于jWebDriver演示F2etest WebDriver的使用，详细jWebDriver的使用请查看官网：<a href="http://jwebdriver.com/" target="_blank">http://jwebdriver.com/</a></p>
            <p>请按照以下操作步骤，可以直接体验整个使用过程：</p>
            <ol>
                <li>npm install mocha -g</li>
                <li>npm install jwebdriver chai@3.5.0</li>
                <li>
                    新建: test.js，内容如下：
                    <pre><code>var JWebDriver = require('jwebdriver');
var chai = require("chai");
chai.should();
chai.use(JWebDriver.chaiSupportChainPromise);

describe('jWebDriver test', function(){

    this.timeout(30000);

    var browser;
    before(function(){
        var driver = new JWebDriver({
            'host': '<%=hostname%>'
        });
        return (browser = driver.session({
            'f2etest.userid': '<%=userid%>',
            'f2etest.apiKey': '<%=apiKey%>',
            'browserName': 'chrome',
            'version': ''
        }));
    });

    it('should search baidu', function(){
        return browser.url('https://www.baidu.com/')
            .find('#kw')
            .should.have.length(1)
            .val('mp3').submit()
            .url()
            .should.contain('wd=mp3');
    });

    after(function(){
        return browser.close();
    });

});</code></pre>
                </li>
                <li>mocha test.js</li>
                <li>
                    执行结果如下：
                    <pre><code>  jWebDriver test
    √ should search baidu (1549ms)

  1 passing (6s)</code></pre>
                </li>
            </ol>
        </div>
    </div>
    <script type="text/javascript">
        $('pre code').each(function(i, block) {
            hljs.highlightBlock(block);
        });    
    </script>
    <% include footer.html %>
</body>
</html>
